package com.sojson.config.condition;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.type.AnnotatedTypeMetadata;

import com.sojson.util.init.InitUtil;

public abstract class MyConfigurationCondition implements Condition {

    /** 默认配置文件的位置 */
    private static boolean envExists = false;

    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        if (!envExists) {
            InitUtil.run((ConfigurableEnvironment)context.getEnvironment());
            envExists = true;
        }
        return matches();
    }

    public abstract boolean matches();

}